<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/12/7
 * Time: 19:11
 */
include_once(ROOTDIR.'include/ap.class.php');

if(empty($_SESSION["userinfo"])){die("<script>top.location.href='index.php'</script>");}

//商户服务窗信息设置
class User_con extends ap
{
    //保存服务窗用户信息
    public function saveuser()
    {
        $userid = $this->userinfo['userid'];
        $into = array(
            'userid' => $userid,
            'appid' => $_POST['appid'],
            'appname' => $_POST['appname'],
            'redirect_uri' => $_POST['redirect_uri'],
            'applyurl' => $_POST['applyurl'],
            'merchant_private_key' => $_POST['merchant_private_key'],
            'merchant_public_key' => $_POST['merchant_public_key'],
        );
//        var_dump($into);die;

        $ishave = $this->viewdata("id","apuser","where userid={$this->userinfo['userid']}");

        if(empty($ishave)){
            $this->setdata("apuser",$into);
        }else{
            $this->updata("apuser",$into,"where id={$ishave['id']}");
        }
        //这个地方没有显示模板
		die(jsfshow('服务窗资料更新成功'));
    }
    
    //保存用户信息
    public function save()
    {
        $userid = $this->userinfo['userid'];
        $into = array(
            'userid' => $userid,
            //'appid' => '',
            //'appname' => '',
            //'redirect_uri' => '',
            //'applyurl' => '',
            //'merchant_private_key' => '',
            //'merchant_public_key' => '',
            'alipay_partner_id' => $_POST['partner_id'],
            'alipay_seller_email' => $_POST['seller_email'],
            'alipay_key' => $_POST['key'],
            'alipay_paytype' => $_POST['paytype'],
        );
        //        var_dump($into);die;
    
        $ishave = $this->viewdata("id","apuser","where userid={$this->userinfo['userid']}");
    
        if(empty($ishave)){
            $this->setdata("apuser",$into);
        }else{
            $this->updata("apuser",$into,"where id={$ishave['id']}");
        }
        //这个地方没有显示模板
        echo jsfshow('支付宝资料更新成功');
        echo "<script>location.href='?g=user&m=member&a=company&selnum=alipay&'+Math.random();</script>";exit;
    }
}